<?php

include_once "model.php";



function render($node) {
	echo '<p>'.$node[NODE_CONTENT].'<span style="font-size:smaller">(Depth: '.$node[NODE_DEPTH].' | <a href="delete.php?id='.$node[NODE_ID].'">delete</a>)</p>';
}

function helper($model, $left_id, $right_id) {
	$middle = $model->get_middle($left_id, $right_id);
	if ($middle != NULL){
		echo '<div class="viewer-block">';
		helper($model, $left_id, $middle[NODE_ID]);
		render($middle);
		helper($model, $middle[NODE_ID], $right_id);
		echo '</div>';
	}
}

$start = $model->get_node(1);
$end = $model->get_node(2);

include("inc/header.inc");
render($start);
helper($model, $start[NODE_ID], $end[NODE_ID]);
render($end);
include("inc/footer.inc");
?>
